import Vue from 'vue'
import VueRouter from 'vue-router'

// import Layout from '@/views/Layout'
// 路由懒加载不用引入
// import Login from '@/views/Login'
// import Home from '@/views/Home'
// import User from '@/views/User'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/layout'
  },
  // 懒加载写法
  {
    path: '/login',
    component: () => import('@/views/Login')
  },
  {
    path: '/layout',
    component: () => import('@/views/Layout'),
    redirect: '/layout/home',
    children: [
      {
        path: 'home',
        component: () => import('@/views/Home')
      },
      {
        path: 'user',
        component: () => import('@/views/User')
      }
    ]

  },
  {
    path: '/search',
    component: () => import('@/views/Search')
  },
  {
    path: '/Search/:keywords', // 参数名: 路径上传递具体值
    component: () => import('@/views/SearchResult')
  },
  {
    path: '/art_detail',
    component: () => import('@/views/Article')
  },
  {
    path: '/user_editor',
    component: () => import('@/views/User/userEdit')
  },
  {
    path: '/chat',
    component: () => import('@/views/User/Chat')
  }
]

const router = new VueRouter({
  routes
})

export default router
